package com.freedom.pms.goods.application.service.query;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freedom.pms.goods.application.converter.GoodsSpuConverter;
import com.freedom.pms.goods.domain.factory.GoodsSpuFactory;
import com.freedom.pms.goods.domain.pojo.bo.GoodsSpuBO;
import com.freedom.pms.goods.domain.repository.GoodsSpuRepository;
import com.freedom.pms.goods.infrastructure.persistence.pojo.query.AdminSpuPageQuery;
import com.freedom.pms.goods.infrastructure.persistence.pojo.vo.AdminGoodsSpuDetailVO;
import com.freedom.pms.goods.infrastructure.persistence.pojo.vo.AdminGoodsSpuPageVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class GoodsSpuQueryService {

    private final GoodsSpuRepository goodsSpuRepository;

    private final GoodsSpuFactory goodsSpuFactory;

    public Page<AdminGoodsSpuPageVO> queryAdminGoodsSpuPage(AdminSpuPageQuery queryParam) {
        Page<GoodsSpuBO> goodsSpuBOPage = goodsSpuRepository.queryGoodsSpuPage(queryParam);
        return goodsSpuFactory.createAdminPageVO(goodsSpuBOPage);
    }

    public AdminGoodsSpuDetailVO findAdminDetail(Integer id) {
        GoodsSpuBO goodsSpuBO = goodsSpuRepository.findAdminDetail(id);
        return goodsSpuFactory.createAdminGoodsSpuDetailO(goodsSpuBO);
    }
}
